* STATA Do file for Chapter 9, Mark R. Beissinger, The Revolutionary City  
version 14
clear all
set more off
log using Logfiles\chapter9.log, replace
* ============================================================================
* STATISTICAL RESULTS APPEARING IN CHAPTER 9
* STATA Do file for Chapter 9  
* Results reported in Chapter 9  
* Author: Mark R. Beissinger  
* Date:  January 2022 
* Princeton, NJ 
* =============================================================================
* WARNING: THIS DO FILE CAN TAKE SOME TIME TO COMPLETE EXECUTION
* =============================================================================
* BEFORE RUNNING, YOU MUST SET THE DEFAULT PATH FOR WHERE THE DATA
*   FILES RESIDE
* =============================================================================
* For this do-file to execute properly, you must first install the following 
*	Stata package:
*		mimrgns from http://fmwww.bc.edu/RePEc/bocode/m
* =============================================================================
* The following datafiles are used for this chapter:
*   revolutionaryeps.dta--Cross-sectional dataset of revolutionary episodes
*   matcheddiffindifflong.dta--Panel dataset of successful revolutions and 
*		matched cases for pre-revolutionary and post-revolutionary periods
*   simplediffindifflong.dta--Panel dataset of successful and failed urban 
*		civic and social revolutionary episodes for pre-revolutionary 
*		and post-revolutionary periods
*   fullsamplediffindifflong.dta--Panel dataset of all revolutionary episodes
*		for pre-revolutonary and post-revolutionary periods
* =============================================================================
* See Appendix 4H of The Revolutionary City for details on how the matched
*    samples were created
* ============================================================================
* Output produced:  Logfiles\chapter9.log
*					Outputfiles\figure9_2.pdf
*					Outputfiles\figure9_2.pdf
* 	--All output from this chapter has been combined into a single file and can 
*		be found in a pdf file (chapter9.pdf) under the "Outputfiles" folder
* =============================================================================
*
* ***************************************************************************
* PLEASE READ--IMPORTANT EXPLANATION OF WHAT FOLLOWS
* ***************************************************************************
*
* In Chapter 9 of The Revolutionary City, the diff-and-diff analyses were
* not used as a way of estimating treatment effects. The reasons for this
* are detailed in Appendix 4G (pp. 488-492), which provides a discussion of
* the ways in which revolutions violate the various assumptions of the 
* diff-in-diff model necessary for estimating treatment effects. Instead, 
* the diff-and-diff setup in Chapter 9 was used for purposes of controlled
* comparison--for describing the evolution of the particular variables examined, 
* to identify trends before and after revolution, and to compare these
* between different types of revolutions, between succcessful and failed 
* revolutionary episodes, and between countries experiencing revolutionary 
* contention and matched counterparts that did not. 
*
* Indeed, many of the comparisons presented in Chapter 9 do not involve "treatment" 
* at all, but rather compare patterns of development after different types of 
* revolutions, or patterns of development in societies experiencing successful
* revolutions with those that experienced failed ones.  There was no "treatment" 
* effect that could be estimated in these cases, and the purpose instead was to
* describe the different trajectories of the variables of interest under these 
* constrasting conditions. The closest this chapter comes to potentially 
* identifying a treatment effect for revolution was in its matched case 
* comparisons that compared societies experiencing revolutionary contention with 
* societies that were similar in many respects but did not experience revolutionary 
* contention over the period. There are considerable issues involved
* in such comparisons, though they are about the best that can be done to estimate
* the counterfactual of what might have happened had revolution never occurred.
* However, I did not estimate a "treatment" effect in these cases, preferring
* instead to use the setup to compare rather than identify causaion. The 
* quasi-"treatment" variable (revny) used in these specifications actually included  
* both treatment and pre-treatment years rather than differentiating between 
* "treatment" and pre-"treatment" years, as a normal diff-in-diff setup would do.
* The year prior to revolutionary onset was used as the base for the comparison. 
* The setup also included a unit-time control. 
*
* In the robustness tests for this chapter, I explore the extent to which a  
* "treatment"  effect (ATET) can be estimated for all of the matched comparisons  
* conducted in the chapter, as well as the extent to which some of the key statistical   
* assumptions for estimating a treatment effect for revolution hold (Please note 
* that, as detailed in The Revolutionary City, there are other statistical
* assumptions necessary for identifying treatment effects that are not tested
* here and that may not hold true for many of the revolutionary episodes in the
* sample).
*
* ***************************************************************************


* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
* INITIAL SET UP OF PROGRAMS USED FOR MULTIPLE IMPUTATION
* 	Programs are called in analyses below
* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++

* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
* Simple comparisons of social vs. urban civic--chp9simpmultimp
* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

quietly{
capture program drop chp9simpmultimp
program chp9simpmultimp
* Multiple imputation 
* Establish sample
keep year location cowcode revid nameofrevolution success leftist urbancivic incgovcommunist $yvar
mi set mlong
* Drop cases that lack pre-treatment information
mi reshape wide $yvar, i(revid) j(year)
local j = 0
local k = 1
local l = 2
drop if $yvar`j'==. & $yvar`k'==. & $yvar`l'==.
mi reshape long $yvar, i(revid) j(year)
* Obtain number of imputations
misstable summarize $yvar, gen(miss)
tab miss$yvar  if (urbancivic==1 | leftist==1), matcell(x)
scalar fir = x[1,1]
scalar sec = x[2,1]
global mnum = 10 * ceil((100 * (sec/(fir + sec)))/10)
display $mnum
drop miss$yvar
* Engage in imp/utation
mi reshape wide $yvar, i(revid) j(year)
* Make lists of variables that do and do not need imputation
forvalues i = 0(1)10 {
* timei yvar
scalar alist`i'=" "
scalar blist`i'=" "
count if $yvar`i'==.
if r(N)>0 {
 scalar alist`i' = "$yvar`i'"
}
if r(N)==0 {
 scalar blist`i' = "$yvar`i'"
}
display alist`i'
display blist`i'
}
* Final computation
local alist alist0 + " " + alist1 + " " + alist2 + " " + alist3 + " " + alist4 + " " + alist5  + " " + alist6  + " " + alist7  + " " + alist8  + " " + alist9  + " " + alist10
local blist blist0 + " " + blist1 + " " + blist2 + " " + blist3 + " " + blist4 + " " + blist5  + " " + blist6  + " " + blist7  + " " + blist8  + " " + blist9  + " " + blist10
display `alist'
display `blist'
scalar afull = `alist'
global afulllist = afull
scalar bfull = `blist'
global bfulllist = bfull
* Register variables to be imputed
mi register imputed $afulllist
misstable summarize $afulllist, gen(miss)
mi xtset, clear
* Impute
mi impute chained (regress) $afulllist = success leftist $bfulllist, add($mnum) rseed (1234) chaindots 
* Engage in analysis
mi reshape long $yvar, i(revid) j(year)
mi xtset revid year
end

* +++++++++++++++++++++++++++++++++++++++++
* Full sample comparisons--chp9fullmultimp
* +++++++++++++++++++++++++++++++++++++++++
capture program drop chp9fullmultimp
program chp9fullmultimp
* Multiple imputation 
* Establish sample
keep year cowcode revid nameofrevolution success leftist urbancivic $yvar
mi set mlong
* Drop cases that lack pre-treatment information
mi reshape wide $yvar, i(revid) j(year)
local j = 0
local k = 1
local l = 2
drop if $yvar`j'==. & $yvar`k'==. & $yvar`l'==.
mi reshape long $yvar, i(revid) j(year)
* Obtain number of imputations
misstable summarize $yvar, gen(miss)
tab miss$yvar, matcell(x)
scalar fir = x[1,1]
scalar sec = x[2,1]
global mnum = 10 * ceil((100 * (sec/(fir + sec)))/10)
display $mnum
drop miss$yvar
* Engage in imputation
mi reshape wide $yvar, i(revid) j(year)
* Make lists of variables that do and do not need imputation
forvalues i = 0(1)10 {
* timei yvar
scalar alist`i'=" "
scalar blist`i'=" "
count if $yvar`i'==.
if r(N)>0 {
 scalar alist`i' = "$yvar`i'"
}
if r(N)==0 {
 scalar blist`i' = "$yvar`i'"
}
display alist`i'
display blist`i'
}
* Final computation
local alist alist0 + " " + alist1 + " " + alist2 + " " + alist3 + " " + alist4 + " " + alist5  + " " + alist6  + " " + alist7  + " " + alist8  + " " + alist9  + " " + alist10
local blist blist0 + " " + blist1 + " " + blist2 + " " + blist3 + " " + blist4 + " " + blist5  + " " + blist6  + " " + blist7  + " " + blist8  + " " + blist9  + " " + blist10
display `alist'
display `blist'
scalar afull = `alist'
global afulllist = afull
scalar bfull = `blist'
global bfulllist = bfull
* Register variables to be imputed
mi register imputed $afulllist
misstable summarize $afulllist, gen(miss)
mi xtset, clear
* Impute
mi impute chained (regress) $afulllist = success $bfulllist, add($mnum) rseed (1234) chaindots 
* Engage in analysis
mi reshape long $yvar, i(revid) j(year)
mi xtset revid year
end

* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
* Matched sample comparisons--chp9fullmultimp--chp9matchmultimp
* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
* Do-file chp9matchmultimp
capture program drop chp9matchmultimp
program chp9matchmultimp
* MULTIPLE IMPUTATION 
* ESTABLISH SAMPLE
keep diffid year country cowcode _prime_id revny revid nameofrevolution revcowcode success startyear freqwt leftist urbancivic $yvar
mi set mlong
* DROP CASES THAT LACK PRE-TREATMENT INFORMATION
mi reshape wide $yvar, i(diffid) j(year)
local j = 0
local k = 1
local l = 2
* Create new marker for those with no pre-treatment values
generate dropmark1=0
replace dropmark1=1 if $yvar`j'==. & $yvar`k'==. & $yvar`l'==.
* Generate var for number of cases within each revid
generate casenum = 1/freqwt
* Create new marker for revs with matched cases marked for dropping
sort revid diffid
by revid:  generate dropmark2 =  (sum(dropmark1))/casenum
* Drop matched cases if no pre-treatment values
drop if revny==0 & dropmark1==1
* Drop revs with no matched cases left
by revid: egen newcount=count(diffid)
drop if newcount==1
* Drop revs and matched cases in which rev itself has no pre-treatment values
by revid:  generate dropmark3 = sum(dropmark2)
drop if dropmark3>=1
* Create new weight variable
replace newcount = newcount - 1
replace freqwt = 1/newcount
replace freqwt=1 if revny==1
drop dropmark1 dropmark2 dropmark3 casenum newcount
mi reshape long $yvar, i(diffid) j(year)
* OBTAIN NUMBER OF IMPUTATIONS
misstable summarize $yvar, gen(miss)
tab miss$yvar  if success==1 & (urbancivic==1 | leftist==1), matcell(x)
scalar fir = x[1,1]
scalar sec = x[2,1]
global mnum = 10 * ceil((100 * (sec/(fir + sec)))/10)
display $mnum
drop miss$yvar
* ENGAGE IN IMPUTATION
mi reshape wide $yvar, i(diffid) j(year)
* Make lists of variables that do and do not need imputation
forvalues i = 0(1)10 {
* timei yvar
scalar alist`i'=" "
scalar blist`i'=" "
count if $yvar`i'==.
if r(N)>0 {
 scalar alist`i' = "$yvar`i'"
}
if r(N)==0 {
 scalar blist`i' = "$yvar`i'"
}
display alist`i'
display blist`i'
}
* Final computation
local alist alist0 + " " + alist1 + " " + alist2 + " " + alist3 + " " + alist4 + " " + alist5  + " " + alist6  + " " + alist7  + " " + alist8  + " " + alist9  + " " + alist10
local blist blist0 + " " + blist1 + " " + blist2 + " " + blist3 + " " + blist4 + " " + blist5  + " " + blist6  + " " + blist7  + " " + blist8  + " " + blist9  + " " + blist10
display `alist'
display `blist'
scalar afull = `alist'
global afulllist = afull
scalar bfull = `blist'
global bfulllist = bfull
* Register variables to be imputed
mi register imputed $afulllist
misstable summarize $afulllist, gen(miss)
mi xtset, clear
* Impute
mi impute chained (regress) $afulllist = revny $bfulllist, add($mnum) rseed (1234) chaindots 
* RESHAPE TO ENGAGE IN ANALYSIS
mi reshape long $yvar, i(diffid) j(year)
mi xtset diffid year
end

}


* ++++++++++++++++++++++
* ANALYSIS BEGINS HERE
* ++++++++++++++++++++++

* ============================================================
* SURVIVAL ANALYSES OF SUCCESSFUL AND UNSUCCESSFUL REVOLUTIONS
* ============================================================
* Analysis and Figure 9.2
clear
use revolutionaryeps.dta, clear
* Establish data as survival data with reglastyr variable--previously carried out
stset reglastyr, failure(died==1) origin (time endyear)
* All social revolutionary
stcox i.success  if leftist==1
stcurve, survival  at1(success=0) at2(success=1) range(0 30) ylabel(0(.1)1) ylabel(, angle(0)) xlabel(0(5)30) xmtick(1(1)30) outfile("Logfiles\surv1grph.dta", replace)
* Test proportional hazards assumption
estat phtest
* All urban civic
stcox i.success  if  urbancivic==1
stcurve, survival  at1(success=0) at2(success=1) range(0 30) ylabel(0(.1)1) ylabel(, angle(0)) xlabel(0(5)30) xmtick(1(1)30) outfile("Logfiles\surv2grph.dta", replace)
* Test proportional hazards assumption
estat phtest
* Combine
use "Logfiles\surv1grph.dta", clear
rename surv2 surv1_A 
rename surv3 surv2_A 
rename _t _tA
append using "Logfiles\surv2grph.dta"
rename surv2 surv1 
rename surv3 surv2 
twoway connected surv1 surv2 _t, sort msymbol(S S) lw(medthin medthin) lcolor(black black) mfcolor(white black) mlcolor(black black) msize(medium medium) mlw(thin thin) || connected surv1_A surv2_A _tA, sort msymbol(O O) lw(medthin medthin) lcolor(black black) mfcolor(white black) mlcolor(black black) msize(medlarge medlarge) mlw(thin thin) xsize(7.5) ysize(7) yline(.5 , lc(gray) lw(medthin)) plotregion(lcolor(black)) xtitle("Years in power after episode", size(small)) ytitle("Probability of survival", xoffset(1) size(small)) ylabel(.20(.10)1.00, format(%9.2fc) labsize(small)) ymtick(.2(.01)1) xlabel(0(5)30, labsize(small)) xmtick(0(1)30) legend(cols(2) pos(6) xoffset(-5) label(1 "Failed urban civic") label(2 "Successful urban civic") label(3 "Failed social") label(4 "Successful social") size(small) order(3 4 1 2) symplacement(center) keygap(1) bmargin(zero))
* graph was exported and edited by hand
*   saved here as pdf
graph export Logfiles\figure9_2.pdf, replace
erase Logfiles\surv1grph.dta
erase Logfiles\surv2grph.dta


* Role of episode length, but not vanguard organization, communist parties, violence in revolutionary contention, civil war
* Regimes that result from episodes that last longer also last in power longer
clear
use revolutionaryeps.dta, clear
* Establish data as survival data with reglastyr variable--previously carried out
stset reglastyr, failure(died==1) origin (time endyear)
* Testing for impact of social civil society repression, revolution, revolutionary organization, civil war, deaths, and episode duration
* V-Dem measure of repression of civil society (higher scores stand for higher repression)
stcox  c.vdcsrepressplus1##c.vdcsrepressplus1 if ongoing==0 & success==1
stcox  c.vdcsrepressplus2##c.vdcsrepressplus2 if ongoing==0 & success==1
stcox  c.vdcsrepressplus3##c.vdcsrepressplus3 if ongoing==0 & success==1
stcox  c.vdcsrepressplus4##c.vdcsrepressplus4 if ongoing==0 & success==1
stcox  c.vdcsrepressplus5##c.vdcsrepressplus5 if ongoing==0 & success==1
stcox  c.vdcsrepressavg1to5##c.vdcsrepressavg1to5 if ongoing==0 & success==1
ttest vdcsrepressavg1to5 if  success==1, by(leftist)
* Vanguard parties and communist rule
* Revolutions based on vanguard parties and communist regimes have no relationship to longevity
stcox  vanguard if ongoing==0 & success==1
stcox  newregimecommunist if ongoing==0 & success==1
* Testing for impact of social revolution, revolutionary organization, civil war, deaths in revolutionary contention, and episode duration
* Shows episode duration as the key factor
stcox  leftist  if ongoing==0 & success==1
stcox  vanguard if ongoing==0 & success==1
stcox  civilwar if ongoing==0 & success==1
stcox  lndeaths if ongoing==0 & success==1
stcox  lnmonthsdur if ongoing==0 & success==1
stcox  leftist vanguard if ongoing==0 & success==1
stcox  leftist civilwar if ongoing==0 & success==1
stcox  leftist lndeaths if ongoing==0 & success==1
stcox  leftist lnmonthsdur if ongoing==0 & success==1
stcox  leftist  vanguard  civilwar lndeaths lnmonths  c.vdcsrepressavg1to5##c.vdcsrepressavg1to5 if ongoing==0 & success==1
* Figure 9.3--graphed at episode lengths of 2 mos, 4 mos, 7 mos, 1 yr, 2 yrs, 4 yrs, 10 yrs
stcox  lnmonthsdur if ongoing==0 & success==1
stcurve, survival at1(lnmonthsdur=.69314718) at2(lnmonthsdur=1.3862944) at3(lnmonthsdur=1.9459101) at4(lnmonthsdur=2.4849066) at5(lnmonthsdur=3.1780538) at6(lnmonthsdur=3.871201) at7(lnmonthsdur=4.7874917) range(0 30) ylabel(0(.1)1) ylabel(, angle(0)) xlabel(0(5)30) xmtick(1(1)30) lpattern(solid solid solid solid solid solid solid) legend(off) title("") lw(medthin medthin medthin medthin medthin medthin medthin) lcolor(black black black black black black black) xsize(7.75) ysize(7) yline(.5 , lc(gray)) plotregion(lcolor(black)) xtitle("Years in power after episode", size(small)) ytitle("Probability of survival", xoffset(1) size(small)) ylabel(.00(.10)1.00, format(%9.2fc) labsize(small)) ymtick(0(.01)1) xlabel(0(5)30, labsize(small)) xmtick(0(1)30)
* graph was exported and then edited by hand
*  saved here as pdf
graph export Logfiles\figure9_3.pdf, replace

* ===============================================================
* STATE CAPACITY IN SUCCESSFUL SOCIAL AND URBAN CIVIC REVOLUTIONS
* ===============================================================
* V-Dem Territorial control
* Multiple imputation
clear
use simplediffindifflong.dta, clear
global yvar = "vdsvstterr"
quietly: chp9simpmultimp
* Successful urban civic vs. successful social
mi estimate, post dots saving(miest, replace):  xtreg $yvar i.leftist##ib(2).year if success==1, fe vce(robust)
mimrgns, at(leftist=(0 1) year=(0 1 2 3 4 5 6 7 8 9 10)) predict(xb) noestimcheck
mi xeq 1: tab leftist if e(N_mi) & year==2 & success==1
display "Data was imputed for " round((100 * sec/(fir + sec)), .1) " percent of observations"
* Complete case sample as robustness test
use simplediffindifflong.dta, clear
xtreg $yvar i.leftist##ib(2).year if success==1, fe vce(robust)
margins leftist#year, noestimcheck

* Military expenditure in the wake of revolution
* Multiple imputation
clear
use simplediffindifflong.dta, clear
global yvar = "milex"
quietly: chp9simpmultimp
* Successful urban civic vs. successful social
mi estimate, post dots saving(miest, replace):  xtreg $yvar i.leftist##ib(2).year if success==1, fe vce(robust)
mimrgns, at(leftist=(0 1) year=(0 1 2 3 4 5 6 7 8 9 10)) predict(xb) noestimcheck
mi xeq 1: tab leftist if e(N_mi) & year==2 & success==1
display "Data was imputed for " round((100 * sec/(fir + sec)), .1) " percent of observations"
* Complete case sample as robustness test
* Military expenditure in the wake of revolution
use simplediffindifflong.dta, clear
xtreg $yvar i.leftist##ib(2).year if success==1, fe vce(robust)
margins leftist#year, noestimcheck

* State capacity (Hanson/Sigman) in the wake of successful social and urban civic revolutions, comparison w. matched samples
* WARNING--reduced sample size
* Matched cases (successful vs. failed revolutions)
* Multiple imputation
clear
use matcheddiffindifflong.dta, clear
global yvar = "statecapacity"
quietly: chp9matchmultimp
* Successful social vs. matched cases
mi estimate, post dots saving(miest, replace):  xtreg $yvar i.revny##ib(2).year if success==1 & leftist==1 [pweight=freqwt], fe cluster(revid)
mimrgns, at(revny=(0 1) year=(0 1 2 3 4 5 6 7 8 9 10)) predict(xb)
display "Regression contained " e(N_clust_mi) " revolutions and " (e(N_g_mi) - e(N_clust_mi)) " matched cases"
* Successful urban civic vs. matched cases
mi estimate, post dots saving(miest, replace):  xtreg $yvar i.revny##ib(2).year if success==1 & urbancivic==1 [pweight=freqwt], fe cluster(revid)
mimrgns, at(revny=(0 1) year=(0 1 2 3 4 5 6 7 8 9 10)) predict(xb)
display "Regression contained " e(N_clust_mi) " revolutions and " (e(N_g_mi) - e(N_clust_mi)) " matched cases"
display "Data was imputed for " round((100 * sec/(fir + sec)), .1) " percent of observations"
* Complete case sample as robustness test
use matcheddiffindifflong.dta, clear
xtreg $yvar i.revny##ib(2).year if success==1 & leftist==1 [pweight=freqwt], fe cluster(revid)
margins revny#year, noestimcheck
display "Regression contained " e(N_clust) " revolutions and " (e(N_g) - e(N_clust)) " matched cases"
ttest $yvar if success==1 & leftist==1 & year>4 & year<=10, by(revny)
xtreg $yvar i.revny##ib(2).year if success==1 & urbancivic==1 [pweight=freqwt], fe cluster(revid)
margins revny#year, noestimcheck
display "Regression contained " e(N_clust) " revolutions and " (e(N_g) - e(N_clust)) " matched cases"
ttest $yvar if success==1 & urbancivic==1 & year>4 & year<=10, by(revny)

* ======================================================
* ECONOMIC GROWTH--MATCHED SAMPLES, DATA FOR FIGURE 9.4
* ======================================================
* Matched cases (successful vs. failed revolutions)
* Multiple imputation
clear
use matcheddiffindifflong.dta, clear
global yvar = "gdpa1990index"
quietly: chp9matchmultimp
* Failed revolutions vs. matched counterparts
mi estimate, post dots saving(miest, replace):  xtreg $yvar i.revny##ib(2).year if success==0 [pweight=freqwt], fe cluster(revid)
mimrgns, at(revny=(0 1) year=(0 1 2 3 4 5 6 7 8 9 10)) predict(xb)
display "Regression contained " e(N_clust_mi) " revolutions and " (e(N_g_mi) - e(N_clust_mi)) " matched cases"
* Results loaded into MS Excel and graphed
* Successful revolutions vs. matched counterparts
mi estimate, post dots saving(miest, replace):  xtreg $yvar i.revny##ib(2).year if success==1 [pweight=freqwt], fe cluster(revid)
mimrgns, at(revny=(0 1) year=(0 1 2 3 4 5 6 7 8 9 10)) predict(xb)
display "Regression contained " e(N_clust_mi) " revolutions and " (e(N_g_mi) - e(N_clust_mi)) " matched cases"
* Results loaded into MS Excel and graphed
display "Data was imputed for " round((100 * sec/(fir + sec)), .1) " percent of observations"
* Complete case sample as robustness test
clear
use matcheddiffindifflong.dta, clear
xtreg $yvar i.revny##ib(2).year if success==0 [pweight=freqwt], fe cluster(revid)
margins revny#year
display "Regression contained " e(N_clust) " revolutions and " (e(N_g) - e(N_clust)) " matched cases"
xtreg $yvar i.revny##ib(2).year if success==1 [pweight=freqwt], fe cluster(revid)
margins revny#year
display "Regression contained " e(N_clust) " revolutions and " (e(N_g) - e(N_clust)) " matched cases"

* ===================================================================
* ECONOMIC GROWTH, SOCIAL AND URBAN CIVIC EPISODES--MATCHED SAMPLES, 
*    FIGURES 9.5 AND 9.6
* ===================================================================
* Social revs. vs. urban civic revs--matched samples
* Multiple imputation
clear
use matcheddiffindifflong.dta, clear
global yvar = "gdpa1990index"
quietly: chp9matchmultimp
* Failed social vs. matched counterparts 
mi estimate, post dots saving(miest, replace):  xtreg $yvar i.revny##ib(2).year if success==0 & leftist==1 [pweight=freqwt], fe cluster(revid)
mimrgns, at(revny=(0 1) year=(0 1 2 3 4 5 6 7 8 9 10)) predict(xb)
display "Regression contained " e(N_clust_mi) " revolutions and " (e(N_g_mi) - e(N_clust_mi)) " matched cases"
* Results loaded into MS Excel and graphed
* Successful social vs. matched counterparts 
mi estimate, post dots saving(miest, replace):  xtreg $yvar i.revny##ib(2).year if success==1 & leftist==1 [pweight=freqwt], fe cluster(revid)
mimrgns, at(revny=(0 1) year=(0 1 2 3 4 5 6 7 8 9 10)) predict(xb)
display "Regression contained " e(N_clust_mi) " revolutions and " (e(N_g_mi) - e(N_clust_mi)) " matched cases"
* Results loaded into MS Excel and graphed
* Failed urban civic vs. matched counterparts
mi estimate, post dots saving(miest, replace):  xtreg $yvar i.revny##ib(2).year if success==0 & urbancivic==1 [pweight=freqwt], fe cluster(revid)
mimrgns, at(revny=(0 1) year=(0 1 2 3 4 5 6 7 8 9 10)) predict(xb)
display "Regression contained " e(N_clust_mi) " revolutions and " (e(N_g_mi) - e(N_clust_mi)) " matched cases"
* Results loaded into MS Excel and graphed
* Successful urban civic vs. matched counterparts 
mi estimate, post dots saving(miest, replace):  xtreg $yvar i.revny##ib(2).year if success==1 & urbancivic==1 [pweight=freqwt], fe cluster(revid)
mimrgns, at(revny=(0 1) year=(0 1 2 3 4 5 6 7 8 9 10)) predict(xb)
display "Regression contained " e(N_clust_mi) " revolutions and " (e(N_g_mi) - e(N_clust_mi)) " matched cases"
* Results loaded into MS Excel and graphed
display "Data was imputed for " round((100 * sec/(fir + sec)), .1) " percent of observations"

* Complete case sample as robustness test
use matcheddiffindifflong.dta, clear
* To obtain values for failed social 
xtreg gdpa1990index i.revny##ib(2).year if success==0 & leftist==1 [pweight=freqwt], cluster(revid) fe
margins i.revny#ib(2).year
display "Regression contained " e(N_clust) " revolutions and " (e(N_g) - e(N_clust)) " matched cases"
* To obtain values for successful social 
xtreg gdpa1990index i.revny##ib(2).year if success==1 & leftist==1 [pweight=freqwt], cluster(revid) fe
margins i.revny#ib(2).year
display "Regression contained " e(N_clust) " revolutions and " (e(N_g) - e(N_clust)) " matched cases"
* To obtain values for failed urban civic  
xtreg gdpa1990index i.revny##ib(2).year if success==0 & urbancivic==1 [pweight=freqwt], cluster(revid) fe
margins i.revny#ib(2).year
display "Regression contained " e(N_clust) " revolutions and " (e(N_g) - e(N_clust)) " matched cases"
* To obtain values for successful urban civic 
xtreg gdpa1990index i.revny##ib(2).year if success==1 & urbancivic==1 [pweight=freqwt], cluster(revid) fe
margins i.revny#ib(2).year
display "Regression contained " e(N_clust) " revolutions and " (e(N_g) - e(N_clust)) " matched cases"

*=======================================================================
* RELATIONSHIP BETWEEN NUMBER OF DEATHS IN REVOLUTIONARY CONTENTION AND 
*    ECONOMIC DECLINE AFTER REVOLUTION
*=======================================================================
* Complete case sample only
clear
use fullsamplediffindifflong.dta, clear
xtreg D.gdpa1990pc lndeaths if year==2 | year==3, re vce(robust)

*=======================================================================
* RELATIONSHIP BETWEEN HENISZ MEASURE OF POLITICAL CONSTRAINTS AND 
*    POST-REVOLUTIONARY SOCIAL REVOLUTIONARY AND URBAN CIVIC GOVERNANCE
*=======================================================================
* Successsful social vs. successful urban civic
* Multiple imputation
clear
use simplediffindifflong.dta, clear
global yvar = "polconiii"
quietly: chp9simpmultimp
* Successful social  vs. successful urban civic 
mi estimate, post dots saving(miest, replace):  xtreg $yvar i.leftist##ib(2).year if success==1, fe vce(robust)
mimrgns, at(leftist=(0 1) year=(0 1 2 3 4 5 6 7 8 9 10)) predict(xb) noestimcheck
* Successful social vs. failed social
mi estimate, post dots saving(miest, replace):  xtreg $yvar i.success##ib(2).year if leftist==1, fe vce(robust)
mimrgns, at(success=(0 1) year=(0 1 2 3 4 5 6 7 8 9 10)) predict(xb) noestimcheck
* Successful urban civic vs. failed urban civic
mi estimate, post dots saving(miest, replace):  xtreg $yvar i.success##ib(2).year if urbancivic==1, fe vce(robust)
mimrgns, at(success=(0 1) year=(0 1 2 3 4 5 6 7 8 9 10)) predict(xb) noestimcheck
display "Data was imputed for " round((100 * sec/(fir + sec)), .1) " percent of observations"
* Complete case sample as robustness test
clear
use simplediffindifflong.dta, clear
xtreg $yvar i.leftist##ib(2).year if success==1, fe vce(robust)
margins leftist#year, noestimcheck
* Successful urban civic vs. failed urban civic
xtreg $yvar i.success##ib(2).year if urbancivic==1, fe vce(robust)
margins success#year, noestimcheck

* Matched samples
* Multiple imputation
clear
use matcheddiffindifflong.dta, clear
global yvar = "polconiii"
quietly: chp9matchmultimp
* Successful social vs. matched counterparts 
mi estimate, post dots saving(miest, replace):  xtreg $yvar i.revny##ib(2).year if success==1 & leftist==1 [pweight=freqwt], fe cluster(revid)
mimrgns, at(revny=(0 1) year=(0 1 2 3 4 5 6 7 8 9 10)) predict(xb)
display "Regression contained " e(N_clust_mi) " revolutions and " (e(N_g_mi) - e(N_clust_mi)) " matched cases"
* Successful urban civic vs. matched counterparts 
mi estimate, post dots saving(miest, replace):  xtreg $yvar i.revny##ib(2).year if success==1 & urbancivic==1 [pweight=freqwt], fe cluster(revid)
mimrgns, at(revny=(0 1) year=(0 1 2 3 4 5 6 7 8 9 10)) predict(xb)
display "Regression contained " e(N_clust_mi) " revolutions and " (e(N_g_mi) - e(N_clust_mi)) " matched cases"
display "Data was imputed for " round((100 * sec/(fir + sec)), .1) " percent of observations"
* Complete case sample as robustness test
use matcheddiffindifflong.dta, clear
xtreg $yvar i.revny##ib(2).year if success==1 & leftist==1 [pweight=freqwt], fe cluster(revid)
margins revny#year, noestimcheck
display "Regression contained " e(N_clust) " revolutions and " (e(N_g) - e(N_clust)) " matched cases"
xtreg $yvar i.revny##ib(2).year if success==1 & urbancivic==1 [pweight=freqwt], fe cluster(revid)
margins revny#year, noestimcheck
display "Regression contained " e(N_clust) " revolutions and " (e(N_g) - e(N_clust)) " matched cases"

*=====================================================================
* HIGHER LEVELS OF CORRUPTION IN URBAN CIVIC REVOLUTIONS (FIGURE 9.7) 
*    AND INFLUENCE ON ECONOMIC GROWTH
*=====================================================================
* Figure 9.7: continuing high levels of corruption after revolution
clear
use simplediffindifflong.dta, clear
* Multiple imputation
global yvar = "vdcorr"
quietly: chp9simpmultimp
* Successful social vs. failed social
mi estimate, post dots saving(miest, replace):  xtreg $yvar i.success##ib(2).year if leftist==1, fe vce(robust)
mimrgns, at(success=(0 1) year=(0 1 2 3 4 5 6 7 8 9 10)) predict(xb) noestimcheck
* Results loaded into MS Excel and graphed
mi xeq 1: tab success if e(N_mi) & year==2 & leftist==1
* Successful urban civic vs. failed urban civic
mi estimate, post dots saving(miest, replace):  xtreg $yvar i.success##ib(2).year if urbancivic==1, fe vce(robust)
mimrgns, at(success=(0 1) year=(0 1 2 3 4 5 6 7 8 9 10)) predict(xb) noestimcheck
* Results loaded into MS Excel and graphed
mi xeq 1: tab success if e(N_mi) & year==2 & urbancivic==1
display "Data was imputed for " round((100 * sec/(fir + sec)), .1) " percent of observations"
* Complete case sample as robustness test
clear
use simplediffindifflong.dta, clear
xtreg $yvar i.success##ib(2).year if leftist==1, fe vce(robust)
margins success#year, noestimcheck
xtreg $yvar i.success##ib(2).year if urbancivic==1, fe vce(robust)
margins success#year, noestimcheck

* Matched samples
* Multiple imputation
clear
use matcheddiffindifflong.dta, clear
global yvar = "vdcorr"
quietly: chp9matchmultimp
* Successful social vs. matched counterparts
mi estimate, post dots saving(miest, replace):  xtreg $yvar i.revny##ib(2).year if success==1 & leftist==1 [pweight=freqwt], fe cluster(revid)
mimrgns, at(revny=(0 1) year=(0 1 2 3 4 5 6 7 8 9 10)) predict(xb)
display "Regression contained " e(N_clust_mi) " revolutions and " (e(N_g_mi) - e(N_clust_mi)) " matched cases"
* Successful urban civic vs. matched counterparts
mi estimate, post dots saving(miest, replace):  xtreg $yvar i.revny##ib(2).year if success==1 & urbancivic==1 [pweight=freqwt], fe cluster(revid)
mimrgns, at(revny=(0 1) year=(0 1 2 3 4 5 6 7 8 9 10)) predict(xb)
display "Regression contained " e(N_clust_mi) " revolutions and " (e(N_g_mi) - e(N_clust_mi)) " matched cases"
display "Data was imputed for " round((100 * sec/(fir + sec)), .1) " percent of observations"
* Complete case sample as robustness test
use matcheddiffindifflong.dta, clear
xtreg $yvar i.revny##ib(2).year if success==1 & leftist==1 [pweight=freqwt], fe cluster(revid)
margins revny#year, noestimcheck
display "Regression contained " e(N_clust) " revolutions and " (e(N_g) - e(N_clust)) " matched cases"
xtreg $yvar i.revny##ib(2).year if success==1 & urbancivic==1 [pweight=freqwt], fe cluster(revid)
margins revny#year, noestimcheck
display "Regression contained " e(N_clust) " revolutions and " (e(N_g) - e(N_clust)) " matched cases"

* Negative effect of corruption on economic growth after successful revolution
* Complete case sample
use simplediffindifflong.dta, clear
xtreg gdpa1990index vdcorr if success==1 & year>2, fe
* Negative effect of corruption on growth is especially evident after successful urban civic revolutions
xtreg gdpa1990index vdcorr if success==1 & urbancivic==0 & year>2, fe
xtreg gdpa1990index vdcorr if success==1 & urbancivic==1 & year>2, fe 


*==============================================
*IMPACT OF REVOLUTION ON INVESTMENT AS % OF GDP
*==============================================
* Impact of revolutionary successs/failure on investment
* Multiple imputation
clear
use simplediffindifflong.dta, clear
global yvar = "investtogdp"
quietly: chp9simpmultimp
* Successful social vs. successful urban civic
mi estimate, post dots saving(miest, replace):  xtreg $yvar i.leftist##ib(2).year if success==1, fe vce(robust)
mimrgns, at(leftist=(0 1) year=(0 1 2 3 4 5 6 7 8 9 10)) predict(xb) noestimcheck
mi xeq 1: tab success if e(N_mi) & year==2 & success==1
display "Data was imputed for " round((100 * sec/(fir + sec)), .1) " percent of observations"
* Complete case sample as robustness test
clear
use simplediffindifflong.dta, clear
xtreg $yvar i.leftist##ib(2).year if success==1, fe vce(robust)
margins leftist#year, noestimcheck

* Matched samples
* Multiple imputation
clear
use matcheddiffindifflong.dta, clear
global yvar = "investtogdp"
quietly: chp9matchmultimp
* Successful social vs. matched counterparts
mi estimate, post dots saving(miest, replace):  xtreg $yvar i.revny##ib(2).year if leftist==1 & success==1 [pweight=freqwt], fe cluster(revid)
mimrgns, at(revny=(0 1) year=(0 1 2 3 4 5 6 7 8 9 10)) predict(xb)
display "Regression contained " e(N_clust_mi) " revolutions and " (e(N_g_mi) - e(N_clust_mi)) " matched cases"
* Successful urban civic vs. matched counterparts
mi estimate, post dots saving(miest, replace):  xtreg $yvar i.revny##ib(2).year if urbancivic==1 & success==1 [pweight=freqwt], fe cluster(revid)
mimrgns, at(revny=(0 1) year=(0 1 2 3 4 5 6 7 8 9 10)) predict(xb)
display "Regression contained " e(N_clust_mi) " revolutions and " (e(N_g_mi) - e(N_clust_mi)) " matched cases"
display "Data was imputed for " round((100 * sec/(fir + sec)), .1) " percent of observations"
* Complete case sample as robustness test
clear
use matcheddiffindifflong.dta, clear
xtreg  $yvar i.revny##ib(2).year if leftist==1 & success==1 [pweight=freqwt], cluster(revid) fe
margins revny#year, noestimcheck
display "Regression contained " e(N_clust) " revolutions and " (e(N_g) - e(N_clust)) " matched cases"
xtreg  $yvar i.revny##ib(2).year if urbancivic==1 & success==1 [pweight=freqwt], cluster(revid) fe
margins revny#year, noestimcheck
display "Regression contained " e(N_clust) " revolutions and " (e(N_g) - e(N_clust)) " matched cases"

*=================================================================
* EFFECT OF SOCIAL AND URBAN CIVIC REVOLUTIONS ON PROPERTY RIGHTS 
*=================================================================
* Matched samples
* Multiple imputation
clear
use matcheddiffindifflong.dta, clear
global yvar = "vdproprts"
quietly: chp9matchmultimp
* Successful social vs. matched counterparts
mi estimate, post dots saving(miest, replace):  xtreg $yvar i.revny##ib(2).year if leftist==1 & success==1 [pweight=freqwt], fe cluster(revid)
mimrgns, at(revny=(0 1) year=(0 1 2 3 4 5 6 7 8 9 10)) predict(xb)
display "Regression contained " e(N_clust_mi) " revolutions and " (e(N_g_mi) - e(N_clust_mi)) " matched cases"
* Successful urban civic vs. matched counterparts
mi estimate, post dots saving(miest, replace):  xtreg $yvar i.revny##ib(2).year if urbancivic==1 & success==1 [pweight=freqwt], fe cluster(revid)
mimrgns, at(revny=(0 1) year=(0 1 2 3 4 5 6 7 8 9 10)) predict(xb)
display "Regression contained " e(N_clust_mi) " revolutions and " (e(N_g_mi) - e(N_clust_mi)) " matched cases"
display "Data was imputed for " round((100 * sec/(fir + sec)), .1) " percent of observations"
* Complete case sample as robustness test
clear
use matcheddiffindifflong.dta, clear
xtreg  $yvar i.revny##ib(2).year if leftist==1 & success==1 [pweight=freqwt], cluster(revid) fe
margins revny#year, noestimcheck
display "Regression contained " e(N_clust) " revolutions and " (e(N_g) - e(N_clust)) " matched cases"
xtreg  $yvar i.revny##ib(2).year if urbancivic==1 & success==1 [pweight=freqwt], cluster(revid) fe
margins revny#year, noestimcheck
display "Regression contained " e(N_clust) " revolutions and " (e(N_g) - e(N_clust)) " matched cases"

*==================================
* EFFECT OF REVOLUTION ON INFLATION
*==================================
* Impact of revolutionary successs/failure on inflation
* Multiple imputation
clear
use fullsamplediffindifflong.dta, clear
* Must alter variable name due to reshaping of data during multiple imputation
generate anninflatwi = anninflat2 
global yvar = "anninflatwi"
quietly: chp9fullmultimp
* Successful vs. failed
mi estimate, post dots saving(miest, replace):  xtreg $yvar i.success##ib(2).year, fe
mimrgns, at(success=(0 1) year=(0 1 2 3 4 5 6 7 8 9 10)) predict(xb) noestimcheck
display "Data was imputed for " round((100 * sec/(fir + sec)), .1) " percent of observations"
drop anninflatwi
* Complete case sample as robustness check
clear
use fullsamplediffindifflong.dta, clear
xtreg anninflat2 i.success##ib(2).year, fe
margins success#year, noestimcheck

* Impact of social and urban civic revolutions on inflation
clear
use simplediffindifflong.dta, clear
* Must alter variable name due to reshaping of data
generate anninflatwi = anninflat2 
global yvar = "anninflatwi"
quietly: chp9simpmultimp
* Successful social vs. successful urban civic
mi estimate, post dots saving(miest, replace):  xtreg $yvar i.leftist##ib(2).year if success==1, re
mimrgns, at(leftist=(0 1) year=(0 1 2 3 4 5 6 7 8 9 10)) predict(xb) noestimcheck
mi xeq 1: tab leftist if e(N_mi) & year==2 & success==1
* Failed social vs. failed urban civic
mi estimate, post dots saving(miest, replace):  xtreg $yvar i.leftist##ib(2).year if success==0, re
mimrgns, at(leftist=(0 1) year=(0 1 2 3 4 5 6 7 8 9 10)) predict(xb) noestimcheck
mi xeq 1: tab leftist if e(N_mi) & year==2 & success==0
display "Data was imputed for " round((100 * sec/(fir + sec)), .1) " percent of observations"
drop anninflatwi
* Complete case sample as robustness test
clear
use simplediffindifflong.dta, clear
xtreg anninflat2 i.leftist##ib(2).year if success==1, re
margins leftist#year
xtreg anninflat2 i.leftist##ib(2).year if success==0, re
margins leftist#year

* Comparison of successful urban civic with matched counterparts
* Multiple imputation
clear
use matcheddiffindifflong.dta, clear
* Must alter variable name due to reshaping of data
generate anninflatwi = anninflat2 
global yvar = "anninflatwi"
quietly: chp9matchmultimp
mi estimate, post dots saving(miest, replace): xtreg $yvar i.revny##ib(2).year if success==1 & urbancivic==1 [pweight=freqwt], cluster(revid) fe
mimrgns, at(revny=(0 1) year=(0 1 2 3 4 5 6 7 8 9 10)) predict(xb)
display "Regression contained " e(N_clust_mi) " revolutions and " (e(N_g_mi) - e(N_clust_mi)) " matched cases"
display "Data was imputed for " round((100 * sec/(fir + sec)), .1) " percent of observations"
drop anninflatwi
* Complete case sample as robustness check
use matcheddiffindifflong.dta, clear
xtreg anninflat2 i.revny##ib(2).year if success==1 & urbancivic==1 [pweight=freqwt], cluster(revid) fe
margins i.revny#ib(2).year, noestimcheck
display "Regression contained " e(N_clust) " revolutions and " (e(N_g) - e(N_clust)) " matched cases"


*=========================================
* EFFECT OF REVOLUTION ON GOVERNMENT DEBT
*=========================================
* Impact of revolutionary successs/failure on government debt
* Multiple imputation
clear
use fullsamplediffindifflong.dta, clear
* Must alter variable name due to reshaping of data
global yvar = "debttogdp"
quietly: chp9fullmultimp
* Successful vs. failed
mi estimate, post dots saving(miest, replace):  xtreg $yvar i.success##ib(2).year, fe
mimrgns, at(success=(0 1) year=(0 1 2 3 4 5 6 7 8 9 10)) predict(xb) noestimcheck
mi xeq 1: tab success if e(N_mi) & year==2
display "Data was imputed for " round((100 * sec/(fir + sec)), .1) " percent of observations"
* Complete case sample as robustness check
clear
use fullsamplediffindifflong.dta, clear
xtreg $yvar i.success##ib(2).year, fe
margins success#year, noestimcheck

* Impact of social and urban civic revolutions on government debt
* Multiple imputation
clear
use simplediffindifflong.dta, clear
global yvar = "debttogdp"
quietly: chp9simpmultimp
* Successful social vs. successful urban civic
mi estimate, post dots saving(miest, replace):  xtreg $yvar i.leftist##ib(2).year if success==1, fe vce(robust)
mimrgns, at(leftist=(0 1) year=(0 1 2 3 4 5 6 7 8 9 10)) predict(xb) noestimcheck
mi xeq 1: tab leftist if e(N_mi) & year==2 & success==1
* Failed social vs. failed urban civic
mi estimate, post dots saving(miest, replace):  xtreg $yvar i.leftist##ib(2).year if success==0, fe vce(robust)
mimrgns, at(leftist=(0 1) year=(0 1 2 3 4 5 6 7 8 9 10)) predict(xb) noestimcheck
mi xeq 1: tab leftist if e(N_mi) & year==2 & success==0
display "Data was imputed for " round((100 * sec/(fir + sec)), .1) " percent of observations"
* Complete case sample as robustness check
clear
use simplediffindifflong.dta, clear
xtreg $yvar i.leftist##ib(2).year if success==1, fe vce(robust)
margins leftist#year, noestimcheck
xtreg $yvar i.leftist##ib(2).year if success==0, fe vce(robust)
margins leftist#year, noestimcheck


*======================================================================
* EFFECT OF REVOLUTION ON V-DEM EQUALITY OF RESOURCES INDEX--FIGURE 9.8
*======================================================================
* Multiple imputation
clear
use matcheddiffindifflong.dta, clear
global yvar = "vdeqdr"
quietly: chp9matchmultimp
* Successful social vs. matched counterparts
mi estimate, post dots saving(miest, replace): xtreg $yvar i.revny##ib(2).year if success==1 & leftist==1 [pweight=freqwt], cluster(revid) fe
mimrgns, at(revny=(0 1) year=(0 1 2 3 4 5 6 7 8 9 10)) predict(xb)
display "Regression contained " e(N_clust_mi) " revolutions and " (e(N_g_mi) - e(N_clust_mi)) " matched cases"
* Results loaded into MS Excel and graphed
* Successful urban civic vs. matched counterparts
mi estimate, post dots saving(miest, replace): xtreg $yvar i.revny##ib(2).year if success==1 & urbancivic==1 [pweight=freqwt], cluster(revid) fe
mimrgns, at(revny=(0 1) year=(0 1 2 3 4 5 6 7 8 9 10)) predict(xb)
display "Regression contained " e(N_clust_mi) " revolutions and " (e(N_g_mi) - e(N_clust_mi)) " matched cases"
* Results loaded into MS Excel and graphed
display "Data was imputed for " round((100 * sec/(fir + sec)), .1) " percent of observations"
* Complete case sample as robustness check
clear
use matcheddiffindifflong.dta, clear
xtreg vdeqdr i.revny##ib(2).year if success==1 & leftist==1 [pweight=freqwt], cluster(revid) fe
margins i.revny#ib(2).year, noestimcheck
display "Regression contained " e(N_clust) " revolutions and " (e(N_g) - e(N_clust)) " matched cases"
xtreg vdeqdr i.revny##ib(2).year if success==1 & urbancivic==1 [pweight=freqwt], cluster(revid) fe
margins i.revny#ib(2).year, noestimcheck
display "Regression contained " e(N_clust) " revolutions and " (e(N_g) - e(N_clust)) " matched cases"

*=========================================
* EFFECT OF REVOLUTION ON HEALTH EQUALITY
*=========================================
* Multiple imputation
clear
use matcheddiffindifflong.dta, clear
global yvar = "vdhealtheq"
quietly: chp9matchmultimp
* Successful social vs. matched counterparts
mi estimate, post dots saving(miest, replace): xtreg $yvar i.revny##ib(2).year if success==1 & leftist==1 [pweight=freqwt], cluster(revid) fe
mimrgns, at(revny=(0 1) year=(0 1 2 3 4 5 6 7 8 9 10)) predict(xb)
display "Regression contained " e(N_clust_mi) " revolutions and " (e(N_g_mi) - e(N_clust_mi)) " matched cases"
* Successful urban civic vs. matched counterparts
mi estimate, post dots saving(miest, replace): xtreg $yvar i.revny##ib(2).year if success==1 & urbancivic==1 [pweight=freqwt], cluster(revid) fe
mimrgns, at(revny=(0 1) year=(0 1 2 3 4 5 6 7 8 9 10)) predict(xb)
display "Regression contained " e(N_clust_mi) " revolutions and " (e(N_g_mi) - e(N_clust_mi)) " matched cases"
display "Data was imputed for " round((100 * sec/(fir + sec)), .1) " percent of observations"
* Complete case sample as robustness check
clear
use matcheddiffindifflong.dta, clear
xtreg vdhealtheq i.revny##ib(2).year if success==1 & leftist==1 [pweight=freqwt], cluster(revid) fe
margins i.revny#ib(2).year, noestimcheck
display "Regression contained " e(N_clust) " revolutions and " (e(N_g) - e(N_clust)) " matched cases"
xtreg vdhealtheq i.revny##ib(2).year if success==1 & urbancivic==1 [pweight=freqwt], cluster(revid) fe
margins i.revny#ib(2).year, noestimcheck
display "Regression contained " e(N_clust) " revolutions and " (e(N_g) - e(N_clust)) " matched cases"

*==============================================
* EFFECT OF REVOLUTION ON EDUCATIONAL EQUALITY
*==============================================
* Multiple imputation
clear
use matcheddiffindifflong.dta, clear
global yvar = "vdeduceq"
quietly: chp9matchmultimp
* Successful social vs. matched counterparts
mi estimate, post dots saving(miest, replace): xtreg $yvar i.revny##ib(2).year if success==1 & leftist==1 [pweight=freqwt], cluster(revid) fe
mimrgns, at(revny=(0 1) year=(0 1 2 3 4 5 6 7 8 9 10)) predict(xb)
display "Regression contained " e(N_clust_mi) " revolutions and " (e(N_g_mi) - e(N_clust_mi)) " matched cases"
* Successful urban civic vs. matched counterparts
mi estimate, post dots saving(miest, replace): xtreg $yvar i.revny##ib(2).year if success==1 & urbancivic==1 [pweight=freqwt], cluster(revid) fe
mimrgns, at(revny=(0 1) year=(0 1 2 3 4 5 6 7 8 9 10)) predict(xb)
display "Regression contained " e(N_clust_mi) " revolutions and " (e(N_g_mi) - e(N_clust_mi)) " matched cases"
display "Data was imputed for " round((100 * sec/(fir + sec)), .1) " percent of observations"
* Complete case sample as robustness check
clear
use matcheddiffindifflong.dta, clear
xtreg vdeduceq i.revny##ib(2).year if success==1 & leftist==1 [pweight=freqwt], cluster(revid) fe
margins i.revny#ib(2).year, noestimcheck
display "Regression contained " e(N_clust) " revolutions and " (e(N_g) - e(N_clust)) " matched cases"
xtreg vdeduceq i.revny##ib(2).year if success==1 & urbancivic==1 [pweight=freqwt], cluster(revid) fe
margins i.revny#ib(2).year, noestimcheck
display "Regression contained " e(N_clust) " revolutions and " (e(N_g) - e(N_clust)) " matched cases"

*==========================================
* EFFECT OF REVOLUTION ON INFANT MORTALITY
*==========================================
* Multiple imputation
clear
use matcheddiffindifflong.dta, clear
global yvar = "e_peinfmor"
quietly: chp9matchmultimp
* Successful social vs. matched counterparts
mi estimate, post dots saving(miest, replace): xtreg $yvar i.revny##ib(2).year if success==1 & leftist==1 [pweight=freqwt], cluster(revid) fe
mimrgns, at(revny=(0 1) year=(0 1 2 3 4 5 6 7 8 9 10)) predict(xb)
display "Regression contained " e(N_clust_mi) " revolutions and " (e(N_g_mi) - e(N_clust_mi)) " matched cases"
* Successful urban civic vs. matched counterparts
mi estimate, post dots saving(miest, replace): xtreg $yvar i.revny##ib(2).year if success==1 & urbancivic==1 [pweight=freqwt], cluster(revid) fe
mimrgns, at(revny=(0 1) year=(0 1 2 3 4 5 6 7 8 9 10)) predict(xb)
display "Regression contained " e(N_clust_mi) " revolutions and " (e(N_g_mi) - e(N_clust_mi)) " matched cases"
display "Data was imputed for " round((100 * sec/(fir + sec)), .1) " percent of observations"
* Complete case sample as robustness check
clear
use matcheddiffindifflong.dta, clear
xtreg e_peinfmor i.revny##ib(2).year if success==1 & leftist==1 [pweight=freqwt], cluster(revid) fe
margins i.revny#ib(2).year, noestimcheck
display "Regression contained " e(N_clust) " revolutions and " (e(N_g) - e(N_clust)) " matched cases"
xtreg e_peinfmor i.revny##ib(2).year if success==1 & urbancivic==1 [pweight=freqwt], cluster(revid) fe
margins i.revny#ib(2).year, noestimcheck
display "Regression contained " e(N_clust) " revolutions and " (e(N_g) - e(N_clust)) " matched cases"

*===================================================
* EFFECT OF REVOLUTION ON UNDER-FIVE CHILD MORTALITY
*===================================================
* Multiple imputation
clear
use matcheddiffindifflong.dta, clear
global yvar = "under5mort"
quietly: chp9matchmultimp
* Successful social vs. matched counterparts
mi estimate, post dots saving(miest, replace): xtreg $yvar i.revny##ib(2).year if success==1 & leftist==1 [pweight=freqwt], cluster(revid) fe
mimrgns, at(revny=(0 1) year=(0 1 2 3 4 5 6 7 8 9 10)) predict(xb)
display "Regression contained " e(N_clust_mi) " revolutions and " (e(N_g_mi) - e(N_clust_mi)) " matched cases"
* Successful urban civic vs. matched counterparts
mi estimate, post dots saving(miest, replace): xtreg $yvar i.revny##ib(2).year if success==1 & urbancivic==1 [pweight=freqwt], cluster(revid) fe
mimrgns, at(revny=(0 1) year=(0 1 2 3 4 5 6 7 8 9 10)) predict(xb)
display "Regression contained " e(N_clust_mi) " revolutions and " (e(N_g_mi) - e(N_clust_mi)) " matched cases"
display "Data was imputed for " round((100 * sec/(fir + sec)), .1) " percent of observations"
* Complete case sample as robustness check
clear
use matcheddiffindifflong.dta, clear
xtreg under5mort i.revny##ib(2).year if success==1 & leftist==1 [pweight=freqwt], cluster(revid) fe
margins i.revny#ib(2).year, noestimcheck
display "Regression contained " e(N_clust) " revolutions and " (e(N_g) - e(N_clust)) " matched cases"
xtreg under5mort i.revny##ib(2).year if success==1 & urbancivic==1 [pweight=freqwt], cluster(revid) fe
margins i.revny#ib(2).year, noestimcheck
display "Regression contained " e(N_clust) " revolutions and " (e(N_g) - e(N_clust)) " matched cases"

*====================================================================
* EFFECT OF REVOLUTION ON INCOME INEQUALITY (GINI INDEX)--FIGURE 9.10
*====================================================================
* Multiple imputation
clear
use simplediffindifflong.dta, clear
global yvar = "e_peginiwi"
quietly: chp9simpmultimp
* Successful urban civic vs. failed urban civic
mi estimate, post dots saving(miest, replace):  xtreg $yvar i.success##ib(2).year if leftist==0, fe vce(robust)
mimrgns, at(success=(0 1) year=(0 1 2 3 4 5 6 7 8 9 10)) predict(xb) noestimcheck
* Results loaded into MS Excel and graphed
mi xeq 1: tab success if e(N_mi) & year==2 & leftist==0
* Successful social vs. failed social
mi estimate, post dots saving(miest, replace):  xtreg $yvar i.success##ib(2).year if leftist==1, fe vce(robust)
mimrgns, at(success=(0 1) year=(0 1 2 3 4 5 6 7 8 9 10)) predict(xb) noestimcheck
* Results loaded into MS Excel and graphed
mi xeq 1: tab success if e(N_mi) & year==2 & leftist==1
* Urban civic, excluding cases of postcommunist transitions
mi estimate, post dots saving(miest, replace): xtreg e_peginiwi i.success##ib(2).year if leftist==0 & incgovcommunist==0, fe vce(robust)
mimrgns, at(success=(0 1) year=(0 1 2 3 4 5 6 7 8 9 10)) predict(xb) noestimcheck
mi xeq 1: tab success if e(N_mi) & year==2 & leftist==0 & incgovcommunist==0
display "Data was imputed for " round((100 * sec/(fir + sec)), .1) " percent of observations"
* Complete case sample as robustness check
clear
use simplediffindifflong.dta, clear
xtreg e_peginiwi i.success##ib(2).year if leftist==0, fe vce(robust)
margins success#year, noestimcheck
tab success if e(N) & year==2 & leftist==0
xtreg e_peginiwi i.success##ib(2).year if leftist==1, fe vce(robust)
margins success#year, noestimcheck
tab success if e(N) & year==2 & leftist==1
* Urban civic, excluding cases of postcommunist transitions
xtreg e_peginiwi i.success##ib(2).year if leftist==0 & incgovcommunist==0, fe vce(robust)
margins success#year, noestimcheck
tab success if e(N) & year==2 & leftist==0 & incgovcommunist==0

*==========================================================
* EFFECT OF REVOLUTION ON STATE/PRIVATE PROPERTY OWNERSHIP
*==========================================================
*  Effect of revolution on state/private property ownership
* Multiple imputation
clear
use simplediffindifflong.dta, clear
global yvar = "vdstown_ord"
quietly: chp9simpmultimp
* Successful urban civic vs. failed urban civic
mi estimate, post dots saving(miest, replace):  xtreg $yvar i.success##ib(2).year if leftist==0, fe vce(robust)
mimrgns, at(success=(0 1) year=(0 1 2 3 4 5 6 7 8 9 10)) predict(xb) noestimcheck
mi xeq 1: tab success if e(N_mi) & year==2 & leftist==0
* Successful social vs. failed social
mi estimate, post dots saving(miest, replace):  xtreg $yvar i.success##ib(2).year if leftist==1, fe vce(robust)
mimrgns, at(success=(0 1) year=(0 1 2 3 4 5 6 7 8 9 10)) predict(xb) noestimcheck
mi xeq 1: tab success if e(N_mi) & year==2 & leftist==1
* Urban civic, excluding cases of postcommunist transitions
mi estimate, post dots saving(miest, replace):  xtreg $yvar i.success##ib(2).year if leftist==0 & incgovcommunist==0, fe vce(robust)
mimrgns, at(success=(0 1) year=(0 1 2 3 4 5 6 7 8 9 10)) predict(xb) noestimcheck
tab success if e(N) & year==2 & leftist==0 & incgovcommunist==0
display "Data was imputed for " round((100 * sec/(fir + sec)), .1) " percent of observations"
* Complete case sample as robustness check
clear
use simplediffindifflong.dta, clear
xtreg vdstown_ord i.success##ib(2).year if leftist==1, fe
margins success#year, noestimcheck
xtreg vdstown_ord i.success##ib(2).year if leftist==0, fe
margins success#year, noestimcheck
* Urban civic, excluding cases of postcommunist transitions
xtreg vdstown_ord i.success##ib(2).year if leftist==0 & incgovcommunist==0, fe vce(robust)
margins success#year, noestimcheck
tab success if e(N) & year==2 & leftist==0 & incgovcommunist==0

*==========================================
* EFFECT OF REVOLUTION ON ETHNIC EXCLUSION
*==========================================
* Multiple imputation failed due to the limited nature of the data
* Using complete case sample only
* Ethnic exclusion
use simplediffindifflong.dta, clear
xtreg exclpop i.success##ib(2).year if  leftist==0, fe vce(robust)
margins success#year, noestimcheck
xtreg exclpop i.success##ib(2).year if  leftist==1, fe vce(robust)
margins success#year, noestimcheck

*==========================================
* EFFECT OF REVOLUTION ON GENDER INEQUALITY
*==========================================
* Compared to matched samples
* Women's political empowerment index
* Multiple imputation
clear
use matcheddiffindifflong.dta, clear
global yvar = "v2x_gender"
quietly: chp9matchmultimp
* Successful social vs. matched counterparts
mi estimate, post dots saving(miest, replace): xtreg $yvar i.revny##ib(2).year if success==1 & leftist==1 [pweight=freqwt], cluster(revid) fe
mimrgns, at(revny=(0 1) year=(0 1 2 3 4 5 6 7 8 9 10)) predict(xb)
display "Regression contained " e(N_clust_mi) " revolutions and " (e(N_g_mi) - e(N_clust_mi)) " matched cases"
* Successful urban civic vs. matched counterparts
mi estimate, post dots saving(miest, replace): xtreg $yvar i.revny##ib(2).year if success==1 & urbancivic==1 [pweight=freqwt], cluster(revid) fe
mimrgns, at(revny=(0 1) year=(0 1 2 3 4 5 6 7 8 9 10)) predict(xb)
display "Regression contained " e(N_clust_mi) " revolutions and " (e(N_g_mi) - e(N_clust_mi)) " matched cases"
display "Data was imputed for " round((100 * sec/(fir + sec)), .1) " percent of observations"

* Women's civil liberties
* Multiple imputation
clear
use matcheddiffindifflong.dta, clear
global yvar = "v2x_gencl"
quietly: chp9matchmultimp
* Successful social vs. matched counterparts
mi estimate, post dots saving(miest, replace): xtreg $yvar i.revny##ib(2).year if success==1 & leftist==1 [pweight=freqwt], cluster(revid) fe
mimrgns, at(revny=(0 1) year=(0 1 2 3 4 5 6 7 8 9 10)) predict(xb)
display "Regression contained " e(N_clust_mi) " revolutions and " (e(N_g_mi) - e(N_clust_mi)) " matched cases"
* Successful urban civic vs. matched counterparts
mi estimate, post dots saving(miest, replace): xtreg $yvar i.revny##ib(2).year if success==1 & urbancivic==1 [pweight=freqwt], cluster(revid) fe
mimrgns, at(revny=(0 1) year=(0 1 2 3 4 5 6 7 8 9 10)) predict(xb)
display "Regression contained " e(N_clust_mi) " revolutions and " (e(N_g_mi) - e(N_clust_mi)) " matched cases"
display "Data was imputed for " round((100 * sec/(fir + sec)), .1) " percent of observations"
* Complete case sample as robustness test
use matcheddiffindifflong.dta, clear
xtreg v2x_gencl i.revny##ib(2).year if success==1 & leftist==1 [pweight=freqwt], cluster(revid) fe
margins i.revny#ib(2).year, noestimcheck
xtreg v2x_gencl i.revny##ib(2).year if success==1 & urbancivic==1 [pweight=freqwt], cluster(revid) fe
margins i.revny#ib(2).year, noestimcheck

* Women's participation in civil society
* Multiple imputation
clear
use matcheddiffindifflong.dta, clear
global yvar = "v2x_gencs"
quietly: chp9matchmultimp
* Successful social vs. matched counterparts
mi estimate, post dots saving(miest, replace): xtreg $yvar i.revny##ib(2).year if success==1 & leftist==1 [pweight=freqwt], cluster(revid) fe
mimrgns, at(revny=(0 1) year=(0 1 2 3 4 5 6 7 8 9 10)) predict(xb)
display "Regression contained " e(N_clust_mi) " revolutions and " (e(N_g_mi) - e(N_clust_mi)) " matched cases"
* Successful urban civic vs. matched counterparts
mi estimate, post dots saving(miest, replace): xtreg $yvar i.revny##ib(2).year if success==1 & urbancivic==1 [pweight=freqwt], cluster(revid) fe
mimrgns, at(revny=(0 1) year=(0 1 2 3 4 5 6 7 8 9 10)) predict(xb)
display "Regression contained " e(N_clust_mi) " revolutions and " (e(N_g_mi) - e(N_clust_mi)) " matched cases"
display "Data was imputed for " round((100 * sec/(fir + sec)), .1) " percent of observations"
* Complete case sample as robustness test
use matcheddiffindifflong.dta, clear
xtreg v2x_gencs i.revny##ib(2).year if success==1 & leftist==1 [pweight=freqwt], cluster(revid) fe
margins i.revny#ib(2).year, noestimcheck
xtreg v2x_gencs i.revny##ib(2).year if success==1 & urbancivic==1 [pweight=freqwt], cluster(revid) fe
margins i.revny#ib(2).year, noestimcheck

* Women's political participation
* Multiple imputation
clear
use matcheddiffindifflong.dta, clear
global yvar = "v2x_genpp"
quietly: chp9matchmultimp
* Successful social vs. matched counterparts
mi estimate, post dots saving(miest, replace): xtreg $yvar i.revny##ib(2).year if success==1 & leftist==1 [pweight=freqwt], cluster(revid) fe
mimrgns, at(revny=(0 1) year=(0 1 2 3 4 5 6 7 8 9 10)) predict(xb)
display "Regression contained " e(N_clust_mi) " revolutions and " (e(N_g_mi) - e(N_clust_mi)) " matched cases"
* Successful urban civic vs. matched counterparts
mi estimate, post dots saving(miest, replace): xtreg $yvar i.revny##ib(2).year if success==1 & urbancivic==1 [pweight=freqwt], cluster(revid) fe
mimrgns, at(revny=(0 1) year=(0 1 2 3 4 5 6 7 8 9 10)) predict(xb)
display "Regression contained " e(N_clust_mi) " revolutions and " (e(N_g_mi) - e(N_clust_mi)) " matched cases"
display "Data was imputed for " round((100 * sec/(fir + sec)), .1) " percent of observations"
* Complete case sample as robustness test
use matcheddiffindifflong.dta, clear
xtreg v2x_genpp i.revny##ib(2).year if success==1 & leftist==1 [pweight=freqwt], cluster(revid) fe
margins i.revny#ib(2).year, noestimcheck
xtreg v2x_genpp i.revny##ib(2).year if success==1 & urbancivic==1 [pweight=freqwt], cluster(revid) fe
margins i.revny#ib(2).year, noestimcheck

* Successful social vs, successful urban civic compared directly 
* Women's political participation
* Multiple imputation
clear
use simplediffindifflong.dta, clear
global yvar = "v2x_genpp"
quietly: chp9simpmultimp
* Successful social vs. successful urban civic
mi estimate, post dots saving(miest, replace):  xtreg $yvar i.leftist##ib(2).year if success==1, fe vce(robust)
mimrgns, at(leftist=(0 1) year=(0 1 2 3 4 5 6 7 8 9 10)) predict(xb) noestimcheck
mi xeq 1: tab leftist if e(N_mi) & year==2 & success==1
display "Data was imputed for " round((100 * sec/(fir + sec)), .1) " percent of observations"
* Complete case sample as robustness test
clear
use simplediffindifflong.dta, clear
xtreg v2x_genpp i.leftist##ib(2).year if success==1, fe vce(robust)
margins leftist#year, noestimcheck

* Women's participation in civil society
* Multiple imputation
clear
use simplediffindifflong.dta, clear
global yvar = "v2x_gencs"
quietly: chp9simpmultimp
* Successful social vs. successful urban civic
mi estimate, post dots saving(miest, replace):  xtreg $yvar i.leftist##ib(2).year if success==1, fe vce(robust)
mimrgns, at(leftist=(0 1) year=(0 1 2 3 4 5 6 7 8 9 10)) predict(xb) noestimcheck
mi xeq 1: tab leftist if e(N_mi) & year==2 & success==1
display "Data was imputed for " round((100 * sec/(fir + sec)), .1) " percent of observations"
* Complete case sample as robustness test
use simplediffindifflong.dta, clear
xtreg v2x_gencs i.leftist##ib(2).year if success==1, fe vce(robust)
margins leftist#year, noestimcheck

* Women's civil liberties
* Multiple imputation
clear
use simplediffindifflong.dta, clear
global yvar = "v2x_gencl"
quietly: chp9simpmultimp
* Successful social vs. successful urban civic
mi estimate, post dots saving(miest, replace):  xtreg $yvar i.leftist##ib(2).year if success==1, fe vce(robust)
mimrgns, at(leftist=(0 1) year=(0 1 2 3 4 5 6 7 8 9 10)) predict(xb) noestimcheck
mi xeq 1: tab leftist if e(N_mi) & year==2 & success==1
display "Data was imputed for " round((100 * sec/(fir + sec)), .1) " percent of observations"
* Complete case sample as robustness test
use simplediffindifflong.dta, clear
xtreg v2x_gencl i.leftist##ib(2).year if success==1, fe vce(robust)
margins leftist#year, noestimcheck

*========================================================
* EFFECT OF REVOLUTION ON POLITICAL KILLING (FIGURE 9.10)
*========================================================
* Compared to matched samples
* Multiple imputation
clear
use matcheddiffindifflong.dta, clear
global yvar = "vdclkill"
quietly: chp9matchmultimp
* Successful social vs. matched counterparts
mi estimate, post dots saving(miest, replace): xtreg $yvar i.revny##ib(2).year if success==1 & leftist==1 [pweight=freqwt], cluster(revid) fe
mimrgns, at(revny=(0 1) year=(0 1 2 3 4 5 6 7 8 9 10)) predict(xb)
display "Regression contained " e(N_clust_mi) " revolutions and " (e(N_g_mi) - e(N_clust_mi)) " matched cases"
* Results loaded into MS Excel and graphed
* Successful urban civic vs. matched counterparts
mi estimate, post dots saving(miest, replace): xtreg $yvar i.revny##ib(2).year if success==1 & urbancivic==1 [pweight=freqwt], cluster(revid) fe
mimrgns, at(revny=(0 1) year=(0 1 2 3 4 5 6 7 8 9 10)) predict(xb)
display "Regression contained " e(N_clust_mi) " revolutions and " (e(N_g_mi) - e(N_clust_mi)) " matched cases"
* Results loaded into MS Excel and graphed
display "Data was imputed for " round((100 * sec/(fir + sec)), .1) " percent of observations"
* Complete case sample as robustness test
use matcheddiffindifflong.dta, clear
xtreg vdclkill i.revny##ib(2).year if success==1 & leftist==1 [pweight=freqwt], cluster(revid) fe
margins i.revny#ib(2).year, noestimcheck
xtreg vdclkill i.revny##ib(2).year if success==1 & urbancivic==1 [pweight=freqwt], cluster(revid) fe
margins i.revny#ib(2).year, noestimcheck

*============================================================
* EFFECT OF REVOLUTION ON POLITICAL CIVIL LIBERTIES, MATCHED 
*    CASES (FIGURE 9.11)
*============================================================
* Compared to matched samples
* Multiple imputation
clear
use matcheddiffindifflong.dta, clear
global yvar = "vdpolitlib"
quietly: chp9matchmultimp
* Successful social vs. matched counterparts
mi estimate, post dots saving(miest, replace): xtreg $yvar i.revny##ib(2).year if success==1 & leftist==1 [pweight=freqwt], cluster(revid) fe
mimrgns, at(revny=(0 1) year=(0 1 2 3 4 5 6 7 8 9 10)) predict(xb)
display "Regression contained " e(N_clust_mi) " revolutions and " (e(N_g_mi) - e(N_clust_mi)) " matched cases"
* Results loaded into MS Excel and graphed
* Successful urban civic vs. matched counterparts
mi estimate, post dots saving(miest, replace): xtreg $yvar i.revny##ib(2).year if success==1 & urbancivic==1 [pweight=freqwt], cluster(revid) fe
mimrgns, at(revny=(0 1) year=(0 1 2 3 4 5 6 7 8 9 10)) predict(xb)
display "Regression contained " e(N_clust_mi) " revolutions and " (e(N_g_mi) - e(N_clust_mi)) " matched cases"
* Results loaded into MS Excel and graphed
display "Data was imputed for " round((100 * sec/(fir + sec)), .1) " percent of observations"
* Complete case sample as robustness test
use matcheddiffindifflong.dta, clear
xtreg vdpolitlib i.revny##ib(2).year if success==1 & leftist==1 [pweight=freqwt], cluster(revid) fe
margins i.revny#ib(2).year, noestimcheck
xtreg vdpolitlib i.revny##ib(2).year if success==1 & urbancivic==1 [pweight=freqwt], cluster(revid) fe
margins i.revny#ib(2).year, noestimcheck

*==========================================================
* EFFECT OF REVOLUTION ON PRIVATE CIVIL LIBERTIES, MATCHED 
*    CASES (FIGURE 9.12)
*==========================================================
* Compared to matched samples
* Multiple imputation
clear
use matcheddiffindifflong.dta, clear
global yvar = "vdclpriv"
quietly: chp9matchmultimp
* Successful social vs. matched counterparts
mi estimate, post dots saving(miest, replace): xtreg $yvar i.revny##ib(2).year if success==1 & leftist==1 [pweight=freqwt], cluster(revid) fe
mimrgns, at(revny=(0 1) year=(0 1 2 3 4 5 6 7 8 9 10)) predict(xb)
display "Regression contained " e(N_clust_mi) " revolutions and " (e(N_g_mi) - e(N_clust_mi)) " matched cases"
* Results loaded into MS Excel and graphed
* Successful urban civic vs. matched counterparts
mi estimate, post dots saving(miest, replace): xtreg $yvar i.revny##ib(2).year if success==1 & urbancivic==1 [pweight=freqwt], cluster(revid) fe
mimrgns, at(revny=(0 1) year=(0 1 2 3 4 5 6 7 8 9 10)) predict(xb)
display "Regression contained " e(N_clust_mi) " revolutions and " (e(N_g_mi) - e(N_clust_mi)) " matched cases"
* Results loaded into MS Excel and graphed
display "Data was imputed for " round((100 * sec/(fir + sec)), .1) " percent of observations"
* Complete case sample as robustness test
use matcheddiffindifflong.dta, clear
xtreg vdclpriv i.revny##ib(2).year if success==1 & leftist==1 [pweight=freqwt], cluster(revid) fe
margins i.revny#ib(2).year, noestimcheck
xtreg vdclpriv i.revny##ib(2).year if success==1 & urbancivic==1 [pweight=freqwt], cluster(revid) fe
margins i.revny#ib(2).year, noestimcheck

*==================================================
* EFFECT OF REVOLUTION ON THE RULE OF LAW, MATCHED 
*    CASES (FIGURE 9.13)
*==================================================
* Compared to matched samples
* Multiple imputation
clear
use matcheddiffindifflong.dta, clear
global yvar = "vdrule"
quietly: chp9matchmultimp
* Successful social vs. matched counterparts
mi estimate, post dots saving(miest, replace): xtreg $yvar i.revny##ib(2).year if success==1 & leftist==1 [pweight=freqwt], cluster(revid) fe
mimrgns, at(revny=(0 1) year=(0 1 2 3 4 5 6 7 8 9 10)) predict(xb)
display "Regression contained " e(N_clust_mi) " revolutions and " (e(N_g_mi) - e(N_clust_mi)) " matched cases"
* Results loaded into MS Excel and graphed
* Successful urban civic vs. matched counterparts
mi estimate, post dots saving(miest, replace): xtreg $yvar i.revny##ib(2).year if success==1 & urbancivic==1 [pweight=freqwt], cluster(revid) fe
mimrgns, at(revny=(0 1) year=(0 1 2 3 4 5 6 7 8 9 10)) predict(xb)
display "Regression contained " e(N_clust_mi) " revolutions and " (e(N_g_mi) - e(N_clust_mi)) " matched cases"
* Results loaded into MS Excel and graphed
display "Data was imputed for " round((100 * sec/(fir + sec)), .1) " percent of observations"
* Complete case sample as robustness test
xtreg vdrule i.revny##ib(2).year if success==1 & leftist==1 [pweight=freqwt], cluster(revid) fe
margins i.revny#ib(2).year, noestimcheck
xtreg vdrule i.revny##ib(2).year if success==1 & urbancivic==1 [pweight=freqwt], cluster(revid) fe
margins i.revny#ib(2).year, noestimcheck

*============================================================
* EFFECT OF REVOLUTION ON GOVERNMENT ACCOUNTABILITY, MATCHED 
*    CASES (FIGURE 9.14)
*============================================================
* Compared to matched samples
* Multiple imputation
clear
use matcheddiffindifflong.dta, clear
global yvar = "vdaccount"
quietly: chp9matchmultimp
* Successful social vs. matched counterparts
mi estimate, post dots saving(miest, replace): xtreg $yvar i.revny##ib(2).year if success==1 & leftist==1 [pweight=freqwt], cluster(revid) fe
mimrgns, at(revny=(0 1) year=(0 1 2 3 4 5 6 7 8 9 10)) predict(xb)
display "Regression contained " e(N_clust_mi) " revolutions and " (e(N_g_mi) - e(N_clust_mi)) " matched cases"
* Results loaded into MS Excel and graphed
* Successful urban civic vs. matched counterparts
mi estimate, post dots saving(miest, replace): xtreg $yvar i.revny##ib(2).year if success==1 & urbancivic==1 [pweight=freqwt], cluster(revid) fe
mimrgns, at(revny=(0 1) year=(0 1 2 3 4 5 6 7 8 9 10)) predict(xb)
display "Regression contained " e(N_clust_mi) " revolutions and " (e(N_g_mi) - e(N_clust_mi)) " matched cases"
* Results loaded into MS Excel and graphed
display "Data was imputed for " round((100 * sec/(fir + sec)), .1) " percent of observations"
* Complete case sample as robustness test
use matcheddiffindifflong.dta, clear
xtreg vdaccount i.revny##ib(2).year if success==1 & leftist==1 [pweight=freqwt], cluster(revid) fe
margins i.revny#ib(2).year, noestimcheck
xtreg vdaccount i.revny##ib(2).year if success==1 & urbancivic==1 [pweight=freqwt], cluster(revid) fe
margins i.revny#ib(2).year, noestimcheck


log close

erase miest.ster

clear
